package com.example.jx;

import java.lang.reflect.Type;
import java.util.List;

import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class JsonUtils {
	// 解析多个对象组合
	public static <T> T parasesJson(String json, Class<T> c) {
		Type listType = new TypeToken<List<T>>() {
		}.getType();
		Gson gson = new Gson();
		Log.d("JsonUtil", gson.fromJson(json, listType).toString());
		return gson.fromJson(json, listType);
	}

	// 解析单个对象
	public static <T> T paraseJson(String json, Class<T> c) {
		Gson gson = new Gson();
		return gson.fromJson(json, c);
	}
}
